package cn.consult.sys.service.impl;

import cn.consult.sys.dao.TWeEquipmentDao;
import cn.consult.sys.dao.TWeOperatingRecordDao;
import cn.consult.sys.entity.TWeEquipment;
import cn.consult.sys.entity.TWeOperatingRecord;
import cn.consult.sys.service.TWeOperatingRecordService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * (TWeOperatingRecord)表服务实现类
 *
 * @author makejava
 * @since 2024-04-12 13:38:34
 */
@Service("tWeOperatingRecordService")
public class TWeOperatingRecordServiceImpl extends ServiceImpl<TWeOperatingRecordDao, TWeOperatingRecord> implements TWeOperatingRecordService {
    @Autowired
    private TWeEquipmentDao tWeEquipmentDao;

    @Override
    public IPage<TWeOperatingRecord> getPage(Map<String, Object> params) {
        //不用连表  就先  查设备编号  设备编号查询信息
        TWeEquipment tWeEquipment = tWeEquipmentDao.selectById(Long.valueOf(params.get("weId").toString()));


        LambdaQueryWrapper<TWeOperatingRecord> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TWeOperatingRecord::getNumber, tWeEquipment.getEquipmentNumber());

        Page<TWeOperatingRecord> page = new Page<>();
        page.setCurrent(Long.parseLong(params.get("pageNum").toString()));
        page.setSize(Long.parseLong(params.get("pageSize").toString()));

        Page<TWeOperatingRecord> tWeOperatingRecordPage = this.baseMapper.selectPage(page, wrapper);


        return tWeOperatingRecordPage;
    }
}

